package com.kongge.viewdisplayframeworklib.model;


import android.content.Context;
import android.text.TextUtils;

import com.kongge.viewdisplayframeworklib.control.GlobalMagager;
import com.kongge.viewdisplayframeworklib.util.EQConstans;

public class LayoutIdFactory {

	public int FindLayoutResId(PageNode pageNode){
		if (pageNode == null) {
			return EQConstans.INVALID_ID;
		}
		if (pageNode.getLayoutId() != EQConstans.INVALID_ID) {
			return pageNode.getLayoutId();
		}
		Context context = GlobalMagager.getGlobalActivity();
		if (context != null && !TextUtils.isEmpty(pageNode.getPageLayoutName())) {
			try {
				int layoutId = context.getResources().getIdentifier(pageNode.getPageLayoutName(), "layout", context.getPackageName());
				pageNode.setLayoutId(layoutId);
				return layoutId;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return EQConstans.INVALID_ID;
	}
	
}
